<?php /* Smarty version 2.6.26, created on 2013-04-12 02:39:27
         compiled from ../templates/item_regist.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'U', '../templates/item_regist.html', 40, false),array('function', 'html_radios', '../templates/item_regist.html', 76, false),array('function', 'html_options', '../templates/item_regist.html', 117, false),)), $this); ?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>コントロールパネル</title>

    <link href="./assets/styles/default.css" rel="stylesheet" />
    <link href="./assets/styles/page/item_form.css" rel="stylesheet" />
	<script src="./assets/scripts/libs/jquery-1.7.1.min.js" type="text/javascript"></script>
	<script src="./assets/scripts/import.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(function(){
			$('.free > p').click(function(){
				var t = $(' > div',$(this).parent());
				var h = t.height();

				if(t.is(":hidden")){
					$(this).addClass("active");
					$('em',this).text('j');
					t.css({"height":"0px"})
					.show()
					.animate({height:h+"px"},300,function(){
						$(this).css({height:""});
					});
				}else {
					$(this).removeClass("active");
					$('em',this).text('g');
					t.animate({height:"0px"},300,function(){
						t.hide().css({height:h+"px"},300)
					});
				}
			});

			$('.close > p').click();

		});
		
		
		$(function() {
			categoryModal({url:	"<?php echo ((is_array($_tmp='Home/Category/index')) ? $this->_run_mod_handler('U', true, $_tmp) : U($_tmp)); ?>
?keepThis=true&parent=3&TB_iframe=true&height=500&width=300&modal=false",
				mode:"tree",container:"#selected_category",trigger:"#id_category a",hidden:'category'});
		});

		
		
	</script>
</head>
<body>

<?php echo $this->_tpl_vars['zhead']; ?>


<div id="container">
	<?php echo $this->_tpl_vars['zmenu']; ?>

    <article>
    	<h2><span>&nbsp;</span>商品管理<p><a href="javascript:;">Open Plugins</a></p></h2>
        <nav>
        	<ul>
		      <li><a href="<?php echo ((is_array($_tmp='Home/Item/index')) ? $this->_run_mod_handler('U', true, $_tmp) : U($_tmp)); ?>
"><span>商品検索</span></a></li>
              <li class="active"><a href="<?php echo ((is_array($_tmp='Home/Item/insert')) ? $this->_run_mod_handler('U', true, $_tmp) : U($_tmp)); ?>
"><span>商品登録</span></a></li>
              <li><a href="<?php echo ((is_array($_tmp='Home/Item/rank')) ? $this->_run_mod_handler('U', true, $_tmp) : U($_tmp)); ?>
"><span>ランキング</span></a></li>
              <li><a href="<?php echo ((is_array($_tmp='Home/Item/set')) ? $this->_run_mod_handler('U', true, $_tmp) : U($_tmp)); ?>
"><span>基本設定</span></a></li>
			</ul>
        </nav>
		<section id="content">
			<h3>商品登録</h3>
			<?php if ($this->_tpl_vars['show_massg']): ?>
			<p class="message">商品情報を登録します。</p>
			<form name="form1" action="<?php echo ((is_array($_tmp='Home/Item/insert')) ? $this->_run_mod_handler('U', true, $_tmp) : U($_tmp)); ?>
" method="post" enctype="multipart/form-data">
				<h4><span>&nbsp;</span>基本情報</h4>
				<input type="hidden" name="method" value="insert"/>
				<table class="formTable">
					<tbody>		
						<tr>
							<th class="must1">状態</th>
							<td>
						    <?php echo smarty_function_html_radios(array('name' => 'goods_status','options' => $this->_tpl_vars['goods_status'],'checked' => $this->_tpl_vars['forms']['goods_status']), $this);?>
<?php echo $this->_tpl_vars['err_mes']['goods_status']; ?>

							</td>
						</tr>
						<tr>
							<th class="must1">商品コード</th>
							<td><input type="text" name="goods_id" class="text" value="<?php echo $this->_tpl_vars['forms']['goods_id']; ?>
" /><?php echo $this->_tpl_vars['err_mes']['goods_id']; ?>
</td>
						</tr>
						<tr>
							<th class="must1">商品名</th>
							<td><input type="text" name="goods_name" class="text" value="<?php echo $this->_tpl_vars['forms']['goods_name']; ?>
" /><?php echo $this->_tpl_vars['err_mes']['goods_name']; ?>
</td>
						</tr>
						<tr>
							<th class="must1">商品種別</th>
							<td>
							<?php echo smarty_function_html_radios(array('name' => 'goods_type','options' => $this->_tpl_vars['goods_type'],'checked' => $this->_tpl_vars['forms']['goods_type']), $this);?>
<?php echo $this->_tpl_vars['err_mes']['goods_type']; ?>
	
							</td>
						</tr>
						<tr>
							<th class="must1">カテゴリ（複数）</th>
								<td>
                            <dd>
							<p class="btn_blank float-left btn_category" id="id_category">
                                	<a href="javascript:;">カテゴリ選択</a>
                            </p>
                                 <input type="hidden" name="category_id" value="<?php echo $this->_tpl_vars['forms']['category_id']; ?>
" />
                            	<ul id="selected_category" class="float-left">
                                      <?php unset($this->_sections['sec1']);
$this->_sections['sec1']['name'] = 'sec1';
$this->_sections['sec1']['start'] = (int)0;
$this->_sections['sec1']['loop'] = is_array($_loop=$this->_tpl_vars['category_data']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$this->_sections['sec1']['step'] = ((int)1) == 0 ? 1 : (int)1;
$this->_sections['sec1']['show'] = true;
$this->_sections['sec1']['max'] = $this->_sections['sec1']['loop'];
if ($this->_sections['sec1']['start'] < 0)
    $this->_sections['sec1']['start'] = max($this->_sections['sec1']['step'] > 0 ? 0 : -1, $this->_sections['sec1']['loop'] + $this->_sections['sec1']['start']);
else
    $this->_sections['sec1']['start'] = min($this->_sections['sec1']['start'], $this->_sections['sec1']['step'] > 0 ? $this->_sections['sec1']['loop'] : $this->_sections['sec1']['loop']-1);
if ($this->_sections['sec1']['show']) {
    $this->_sections['sec1']['total'] = min(ceil(($this->_sections['sec1']['step'] > 0 ? $this->_sections['sec1']['loop'] - $this->_sections['sec1']['start'] : $this->_sections['sec1']['start']+1)/abs($this->_sections['sec1']['step'])), $this->_sections['sec1']['max']);
    if ($this->_sections['sec1']['total'] == 0)
        $this->_sections['sec1']['show'] = false;
} else
    $this->_sections['sec1']['total'] = 0;
if ($this->_sections['sec1']['show']):

            for ($this->_sections['sec1']['index'] = $this->_sections['sec1']['start'], $this->_sections['sec1']['iteration'] = 1;
                 $this->_sections['sec1']['iteration'] <= $this->_sections['sec1']['total'];
                 $this->_sections['sec1']['index'] += $this->_sections['sec1']['step'], $this->_sections['sec1']['iteration']++):
$this->_sections['sec1']['rownum'] = $this->_sections['sec1']['iteration'];
$this->_sections['sec1']['index_prev'] = $this->_sections['sec1']['index'] - $this->_sections['sec1']['step'];
$this->_sections['sec1']['index_next'] = $this->_sections['sec1']['index'] + $this->_sections['sec1']['step'];
$this->_sections['sec1']['first']      = ($this->_sections['sec1']['iteration'] == 1);
$this->_sections['sec1']['last']       = ($this->_sections['sec1']['iteration'] == $this->_sections['sec1']['total']);
?>
											<li id="<?php echo $this->_tpl_vars['category_data'][$this->_sections['sec1']['index']]['category_cd']; ?>
"><a href="javascript:;" class="delete_category">削除</a> <?php echo $this->_tpl_vars['category_data'][$this->_sections['sec1']['index']]['category_name']; ?>
</li>
                                      <?php endfor; endif; ?>
                                </ul>
						</dd>
                          <?php echo $this->_tpl_vars['err_mes']['category_id']; ?>
</td>
						</tr>
						<tr>
							<th class="must1">本体価格</th>
							<td><input type="text" name="goods_unitprice" class="short" value="<?php echo $this->_tpl_vars['forms']['goods_unitprice']; ?>
"/>円（税込み<span id="tax_in"><?php echo $this->_tpl_vars['forms']['goods_unitprice']; ?>
</span>円）<?php echo $this->_tpl_vars['err_mes']['goods_unitprice']; ?>
</td>
						</tr>
						<tr>
							<th class="must1">在庫</th>
							<td>
								<select name="goods_stockstatus">
									  <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['goods_stockstatus'],'selected' => $this->_tpl_vars['forms']['goods_stockstatus']), $this);?>

								</select>
								<?php echo $this->_tpl_vars['err_mes']['goods_stockstatus']; ?>

							</td>
						</tr>
						<tr>
							<th class="must1">商品画像（複数）</th>
							<td>
							<div id="img" >
							
							<?php $_from = $this->_tpl_vars['formsimg']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }$this->_foreach['member'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['member']['total'] > 0):
    foreach ($_from as $this->_tpl_vars['k'] => $this->_tpl_vars['v']):
        $this->_foreach['member']['iteration']++;
?>
								<div id="<?php echo $this->_tpl_vars['v']['id']; ?>
">
								<img width="240" src="<?php echo $this->_tpl_vars['v']['img']; ?>
"><br>
								<a class="delete_mini" onclick="remove_img(<?php echo $this->_tpl_vars['v']['id']; ?>
);" 
								href="javascript:;">削除</a>
								<input type="hidden" value="<?php echo $this->_tpl_vars['v']['img']; ?>
" name="upload_image_name[]">
								</div>
						    <?php endforeach; endif; unset($_from); ?>	
							
							</div>
							<div style="clear:both"></div>
							<input id="fileToUpload" type="file" name="goods_image" value="<?php echo $this->_tpl_vars['forms']['goods_image']; ?>
" onchange="return ajaxFileUpload('fileToUpload');" ></td>
						</tr>
						<tr>
							<th class="must1">発行月</th>
							<td>
							<select name="goods_issuedate">
							<?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['select_month'],'selected' => $this->_tpl_vars['forms']['goods_issuedate']), $this);?>

							</select>
							<?php echo $this->_tpl_vars['err_mes']['goods_issuedate']; ?>
</td>
						</tr>
						<tr>
							<th class="must1">仕様</th>
							<td><input type="text" name="goods_style" class="text" value="<?php echo $this->_tpl_vars['forms']['goods_style']; ?>
" /><?php echo $this->_tpl_vars['err_mes']['goods_style']; ?>
</td>
						</tr>
						<tr>
							<th class="must1">フラグ</th>
							<td>
								 <?php $_from = $this->_tpl_vars['goods_mark']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }$this->_foreach['member'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['member']['total'] > 0):
    foreach ($_from as $this->_tpl_vars['kk'] => $this->_tpl_vars['vv']):
        $this->_foreach['member']['iteration']++;
?>
					   		     <?php $this->assign('goods_mark', "goods_mark".($this->_tpl_vars['kk'])); ?>
							    <label><input type="checkbox" name="goods_mark<?php echo $this->_tpl_vars['kk']; ?>
"  <?php if ($this->_tpl_vars['forms'][$this->_tpl_vars['goods_mark']] == $this->_tpl_vars['kk']): ?> checked="true" <?php endif; ?> value="<?php echo $this->_tpl_vars['kk']; ?>
" /><?php echo $this->_tpl_vars['vv']; ?>
</label>
						         <?php endforeach; endif; unset($_from); ?><?php echo $this->_tpl_vars['err_mes']['goods_mark1']; ?>
<?php echo $this->_tpl_vars['err_mes']['goods_mark2']; ?>

							</td>
						</tr>
						<tr>
							<th class="must1">単位</th>
							<td>
								<select name="goods_unit">
									<?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['goods_unit'],'selected' => $this->_tpl_vars['forms']['goods_unit']), $this);?>

								</select><?php echo $this->_tpl_vars['err_mes']['goods_unit']; ?>

							</td>
						</tr>
						<tr>
							<th class="must1">キャッチコピー</th>
							<td><input type="text" name="goods_slogan" class="text" value="<?php echo $this->_tpl_vars['forms']['goods_slogan']; ?>
" /><?php echo $this->_tpl_vars['err_mes']['goods_slogan']; ?>
</td>
						</tr>
						<tr>
							<th>表示順</th>
							<td><input type="text" name="goods_order" value="<?php echo $this->_tpl_vars['forms']['goods_order']; ?>
" class="smartspinner" /></td>
						</tr>
						<tr>
							<th class="must1">META Description</th>
							<td><textarea name="metadescription"><?php echo $this->_tpl_vars['forms']['metadescription']; ?>
</textarea><?php echo $this->_tpl_vars['err_mes']['metadescription']; ?>
</td>
						</tr>
						<tr>
							<th class="must1">META Keyword</th>
							<td><textarea name="metakeyword"><?php echo $this->_tpl_vars['forms']['metakeyword']; ?>
</textarea><?php echo $this->_tpl_vars['err_mes']['metakeyword']; ?>
</td>
						</tr>
						<tr>
							<th>試し読みURL</th>
							<td><input type="text" name="tryURL" class="text" value="<?php echo $this->_tpl_vars['forms']['tryURL']; ?>
" /><?php echo $this->_tpl_vars['err_mes']['tryURL']; ?>
</td>
						</tr>
						<tr>
							<th>外部URL</th>
							<td><input type="text" name="outsideURL" class="text" value="<?php echo $this->_tpl_vars['forms']['outsideURL']; ?>
" /><?php echo $this->_tpl_vars['err_mes']['outsideURL']; ?>
</td>
						</tr>
						<tr>
							<th>社内コメント</th>
							<td><textarea name="insideappraise"><?php echo $this->_tpl_vars['forms']['insideappraise']; ?>
</textarea><?php echo $this->_tpl_vars['err_mes']['insideappraise']; ?>
</td>
						</tr>
						<tr>
							<th>販売開始日時</th>
							<td><input type="text" name="sellbegin" class="text_date" value="<?php echo $this->_tpl_vars['forms']['sellbegin']; ?>
" /><?php echo $this->_tpl_vars['err_mes']['sellbegin']; ?>
</td>
						</tr>
						<tr>
							<th>販売終了日時</th>
							<td><input type="text" name="sellend" class="text_date" value="<?php echo $this->_tpl_vars['forms']['sellend']; ?>
" /><?php echo $this->_tpl_vars['err_mes']['sellend']; ?>
</td>
						</tr>
					</tbody>
				</table>

				 <div class="free">
					<p>
						<em>j</em>
						フリースペース1
					</p>
					<div>
						<table class="formTable">
							<tbody>
								<tr>
									<td>
										<textarea name="freespace1" class="mce_edit"><?php echo $this->_tpl_vars['forms']['freespace1']; ?>
</textarea><?php echo $this->_tpl_vars['err_mes']['freespace1']; ?>

									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>

				 <div class="free close">
					<p>
						<em>j</em>
						フリースペース2
					</p>
					<div>
						<table class="formTable">
							<tbody>
								<tr>
									<td>
										<textarea name="freespace2" class="mce_edit"><?php echo $this->_tpl_vars['forms']['freespace2']; ?>
</textarea><?php echo $this->_tpl_vars['err_mes']['freespace2']; ?>

									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>

				 <div class="free close">
					<p>
						<em>j</em>
						フリースペース3
					</p>
					<div>
						<table class="formTable">
							<tbody>
								<tr>
									<td>
										<textarea name="freespace3" class="mce_edit"><?php echo $this->_tpl_vars['forms']['freespace3']; ?>
</textarea><?php echo $this->_tpl_vars['err_mes']['freespace3']; ?>

									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>

				<p class="button">
					<button type="submit"  class="submit"><span>登録</span></button>
				</p>
			</form>
		<?php else: ?>
			<p class="message"><?php echo $this->_tpl_vars['message']; ?>
</p>
			
			
			<ul class="result_btn clear" style="margin-top:20px;">
                <li><a href="<?php echo ((is_array($_tmp='Home/Item/index')) ? $this->_run_mod_handler('U', true, $_tmp) : U($_tmp)); ?>
">一覧に戻る</a></li>
                <li><a href="<?php echo ((is_array($_tmp='Home/Item/insert')) ? $this->_run_mod_handler('U', true, $_tmp) : U($_tmp)); ?>
">続けて新規登録する</a></li>
            <?php if (isset ( $this->_tpl_vars['forms']['id'] )): ?>
                <li><a href="<?php echo ((is_array($_tmp='Home/Item/update')) ? $this->_run_mod_handler('U', true, $_tmp) : U($_tmp)); ?>
?id=<?php echo $this->_tpl_vars['forms']['id']; ?>
">登録した内容を更新する</a></li>
            <?php endif; ?>
        	</ul>
			
		<?php endif; ?>
		</section>
	</article>
</div>

<script type="text/javascript" src="./assets/scripts/plugins/ajaxfileupload.js"></script>

<script type="text/javascript">

	function ajaxFileUpload(id)
	{
		
		$.ajaxFileUpload
		(
			{
				url:'Home_Item_ajaximage.html',
				secureuri:false,
				fileElementId:id,
				dataType: 'json',
				data:{name:'logan' },
				
				success: function (data, status)
				{
					if(typeof(data.error) != 'undefined')
					{
						if(data.error != '')
						{
							alert(data.error);
						}else
						{	
							$("#img").append('<div style="clear:both" id='+data.id+'><img src="'+data.msg+'" width="240"><br><a href="javascript:;" onclick="remove_img('+data.id+');" class="delete_mini">削除</a><input type="hidden" name="upload_image_name[]" value="'+data.path+'"></div>');
							$(".filename").html('No file selected');
						}
					}
				},
				error: function (data, status, e)
				{
					alert(e);
				}
			}
		)
		return false;
	}
	
	function remove_img(id){
		$.ajax({
		 type: "POST",
		 url: "Home_Item_ajaxdeleteimage.html",
		 data: {"filename":$("#"+id+">img").attr("src")},
		 success: function(msg){ $("#"+id).remove(); } 
		});
		
		
	}
</script>	

<?php echo $this->_tpl_vars['zfooter']; ?>

</body>
</html>